<?php

class Sgit_Filter_Size implements Zend_Filter_Interface
{
    /**
     * Defined by Zend_Filter_Interface
     *
     * Returns $value
     *
     * @param  string $value
     * @return float
     */
    public function filter($size,$precision=2,$codigo=true)
    {
        $base = log($size) / log(1024);
        $suffixes = array('bytes', 'KB', 'MB', 'GB', 'TB');   

        $code=($codigo) ? $suffixes[floor($base)] : '';
        return round(pow(1024, $base - floor($base)), $precision) . $code;

    }
}



